package com.zzyy.study.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @auther zzyy
 * @create 2025-01-03 13:50
 */
@Aspect
@Component
@Slf4j
public class DemoAspect
{
    @Pointcut("(@target(org.springframework.web.bind.annotation.RestController)) " +
            "&& within(com.zzyy.study..*) && execution(public * *(..))")

    public void pointcut() {}

    @Around(value = "pointcut()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
    {
        log.info("Aop 进入");
        //主业务逻辑，放行O(∩_∩)O
        Object proceed = proceedingJoinPoint.proceed();
        log.info("Aop 退出");

        return proceed;
    }
}
